﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using TFXK.BLL;
using log4net;
using TFXK.Model;

public partial class MyControls_XLTJControl : System.Web.UI.UserControl
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly TravelLinesBLL bllTravelLines = new TravelLinesBLL();
    int rowCount = 0;
    private int cityid = 0;

    /// <summary>
    /// 出境、国内
    /// </summary>
    private string travelTypeCode = "";

    //旅游类型
    public string TravelTypeCode
    {
        get { return travelTypeCode; }
        set { travelTypeCode = value; }
    }

    private string mapImgUrl = string.Empty;

    //地图
    public string MapImgUrl
    {
        get { return mapImgUrl; }
        set { mapImgUrl = value; }
    }

    /// <summary>
    /// 城市编号
    /// </summary>
    public int CityID
    {
        get { return cityid; }
        set { cityid = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                BindLeftNews();
            }
        }
        catch (Exception ex) {
            log.Error(ex.Message);
        }
    }
    //绑定推荐
    public void BindLeftNews() {
        //根据城市 获取推荐信息
        //this.rptTuiJianLine.DataSource = bllTravelLines.GetWebListTuiJian(8, 1, CityID, out rowCount);
        TravelTypeCode = Request.Url.ToString().Substring(21, 2);

        if (TravelTypeCode.Equals("GN"))
        {
            rptTuiJianLine.DataSource = bllTravelLines.GetWebList(11, 1, "", "gnly", 0, out rowCount);
        }
        else if (TravelTypeCode.Equals("CJ"))
        {
            rptTuiJianLine.DataSource = bllTravelLines.GetWebList(11, 1, "", "cjly", 0, out rowCount);
        }
        else
        {
           rptTuiJianLine.DataSource = bllTravelLines.GetWebList(11, 1, "", "gnly", 0, out rowCount);
        }
        rptTuiJianLine.DataBind();

         //Category cityModel = bllCategory.GetModel(CityID);
         //if (cityModel != null) {
         //    switch (cityModel.title) { 
         //        case "三亚":
         //            imgMaps.ImageUrl = "sanya.jpg";
         //            break;
         //    }
         //}
        //TravelTypeCode = Request.Url.ToString().Substring(21, 2);

        if (string.IsNullOrEmpty(MapImgUrl))
        {
            if (TravelTypeCode.Equals("GN"))
            {
                imgMaps.ImageUrl = "../Maps/guonei.jpg";
            }
            else if (TravelTypeCode.Equals("CJ"))
            {
                imgMaps.ImageUrl = "../Maps/guowai.jpg";
            }
            else {
                imgMaps.ImageUrl = "../Maps/guonei.jpg";
            }
        }
        else
        {
            imgMaps.ImageUrl = "../Maps/" + MapImgUrl;
        }

        hlklink.NavigateUrl = imgMaps.ImageUrl;
    }
    public string GetLineLink(object tids, object id)
    {
        int tid = int.Parse(tids + "");
        if (tid == 41)
        {
            return "GN_TravelInfo.aspx?Key=" + id;
        }
        else if (tid == 42)
        {
            return "CJ_TravelInfo.aspx?Key=" + id;
        }
        else if (tid == 43)
        {
            return "ZY_TravelInfo.aspx?Key=" + id;
        }
        else if (tid == 44)
        {
            return "YL_TravelInfo.aspx?Key=" + id;
        }
        else
        {
            return "GN_TravelInfo.aspx?Key=" + id;
        }
    }
}
